<?php

namespace App\Http\Controllers\Admin;

use App\Http\Controllers\Controller;
use App\Models\User;
use App\Traits\Admin\DashboardViewShareDataTrait;
use Illuminate\Http\Request;

class UserController extends Controller
{
    use DashboardViewShareDataTrait;
    /**
     * 用户列表
     * @return string
     */
    public function index()
    {
        $this->shareData();
        return view('admin.user.index', [
            'title' => '用户列表',
            'activeModule' => 'core',
            'activeMenu' => 'core.user-list',
            'users' => User::orderBy('id', 'desc')->paginate(2)->withQueryString(),
        ])->fragmentIf(request()->hasHeader('HX-Request'), 'content');
    }

    public function delete(User $user)
    {
        $user->delete();
    }

}
